/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package formula.one.urjc.principal.view;

import formula.one.urjc.dueño.controlador.ControladorFactory;
import formula.one.urjc.escuderia.Escuderia;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;

/**
 *
 * @author santiago
 */
public class ventanaDuenoEscuderia extends JFrame{

    /**
     * Creates new form ventanaDuenoEscuderia
     */
    public ventanaDuenoEscuderia(Escuderia escuderia) {
        initComponents();
        cFactory=new ControladorFactory(escuderia);
    }

    
    public void cerrarVentanas() {
        escritorioEscuderia.removeAll() ;
        escritorioEscuderia.updateUI() ; 
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        escritorioEscuderia = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuGeneral = new javax.swing.JMenu();
        jMenuItemDatos = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItemPilotos = new javax.swing.JMenuItem();
        jMenuItemEntreno = new javax.swing.JMenuItem();
        jMenuItemEquipo = new javax.swing.JMenuItem();
        jMenuOut = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(600, 700));

        escritorioEscuderia.setPreferredSize(new java.awt.Dimension(600, 700));
        escritorioEscuderia.setRequestFocusEnabled(false);

        jMenuGeneral.setText("Escudería");

        jMenuItemDatos.setText("Datos Generales");
        jMenuItemDatos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDatosActionPerformed(evt);
            }
        });
        jMenuGeneral.add(jMenuItemDatos);

        jMenuItem1.setText("Crear Coches");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenuGeneral.add(jMenuItem1);

        jMenuItemPilotos.setText("Gestión de Pilotos");
        jMenuItemPilotos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemPilotosActionPerformed(evt);
            }
        });
        jMenuGeneral.add(jMenuItemPilotos);

        jMenuItemEntreno.setText("Organizar Entrenos");
        jMenuItemEntreno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemEntrenoActionPerformed(evt);
            }
        });
        jMenuGeneral.add(jMenuItemEntreno);

        jMenuItemEquipo.setText("Equipos de Competición");
        jMenuItemEquipo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemEquipoActionPerformed(evt);
            }
        });
        jMenuGeneral.add(jMenuItemEquipo);

        jMenuBar1.add(jMenuGeneral);

        jMenuOut.setText("Log Out");
        jMenuOut.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenuOutMouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenuOut);
        jMenuOut.getAccessibleContext().setAccessibleParent(this);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(escritorioEscuderia, javax.swing.GroupLayout.DEFAULT_SIZE, 678, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(escritorioEscuderia, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItemDatosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDatosActionPerformed
        cerrarVentanas();
        escritorioEscuderia.add(cFactory.getControlDatos().mostrarPantalla());
    }//GEN-LAST:event_jMenuItemDatosActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        cerrarVentanas(); 
        escritorioEscuderia.add(cFactory.getControlCoches().mostrarPantalla());
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItemPilotosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPilotosActionPerformed
        cerrarVentanas();  
        escritorioEscuderia.add(cFactory.getControlFichaje().mostrarPantalla());
    }//GEN-LAST:event_jMenuItemPilotosActionPerformed

    private void jMenuItemEntrenoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEntrenoActionPerformed
        cerrarVentanas();  
        escritorioEscuderia.add(cFactory.getControlEntreno().mostrarPantalla());
    }//GEN-LAST:event_jMenuItemEntrenoActionPerformed

    private void jMenuItemEquipoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEquipoActionPerformed
        cerrarVentanas(); 
        escritorioEscuderia.add(cFactory.getControlEquipo().mostrarPantalla());
    }//GEN-LAST:event_jMenuItemEquipoActionPerformed

    private void jMenuOutMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuOutMouseClicked
         dispose();
        Login vL=new Login();
        vL.setLocationRelativeTo(null);
        vL.setVisible(true) ;
    }//GEN-LAST:event_jMenuOutMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ventanaDuenoEscuderia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ventanaDuenoEscuderia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ventanaDuenoEscuderia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ventanaDuenoEscuderia.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //new ventanaDuenoEscuderia().setVisible(true);
            }
        });
    }
    private ControladorFactory cFactory;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane escritorioEscuderia;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu jMenuGeneral;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItemDatos;
    private javax.swing.JMenuItem jMenuItemEntreno;
    private javax.swing.JMenuItem jMenuItemEquipo;
    private javax.swing.JMenuItem jMenuItemPilotos;
    private javax.swing.JMenu jMenuOut;
    // End of variables declaration//GEN-END:variables
}
